package com.bjwl.web.contrlller.admin;

import com.bjwl.pojo.Proper;
import com.bjwl.service.ProperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.jws.WebParam;
import java.util.ArrayList;

/**
 * @Author: dzx
 * @Date:Create：in 2020/6/1 19:00
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Controller
@RequestMapping("/proper")
public class ProperController {

    @Autowired
    private ProperService properService;


    /**
     * 展示所有
     * @param model
     * @return
     */
    @RequestMapping("findAllProper")
    public String findAllProper(Model model){
        ArrayList<Proper> allProper = properService.findAllProper();
        model.addAttribute("propers",allProper);
        return "main_oa/Notice-list";
    }

    /**
     * 修改前查询
     * @param id
     * @param model
     * @return
     */
    @RequestMapping("upadteProperStart")
    public String upadteProperStart(Integer id,Model model){
        Proper properById = properService.findProperById(id);
        model.addAttribute("proper",properById);
        return "main_oa/Notice-edit";
    }

    /**
     * 修改
     * @param proper
     * @return
     */
    @RequestMapping("upadteProperEnd")
    public @ResponseBody boolean upadteProperEnd(@RequestBody Proper proper){
        properService.upadteProperById(proper);
        return true;
    }


}
